<include file="Finance:leftmenubaodan" />
<div class="content-right fl">
	<h1 class="content-right-title">报单</h1>
	
	<form action="" id="form" method="POST">
       
       <div class="formitems" >
        <label class="fi-name"><span class="colorRed">*</span>订单类型：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="order_type" checked  value="1" name="order_type" >新合伙人报单</label>
<!--                <label><input type="radio" class="order_type" value="2" name="order_type" >重复进货</label>-->
            </div>
            <span class="fi-help-text" style="color:red;"></span>
        </div>
    </div>
    
    
       <div class="formitems">  
			<label class="fi-name"><span class="colorRed">*</span><span id="relaname_text">姓名</span>：</label>
			<div class="form-controls">
				<input  type="text" id="realname" class="input large" name="realname" >
			</div>
		</div>

       <div class="formitems">  
			<label class="fi-name"><span class="colorRed">*</span><span id="mobile_text">手机号</span>：</label>
			<div class="form-controls">
				<input  type="text" id="mobile" class="input large" name="mobile" maxlength="11">
			</div>
		</div>

		<div id="type1">
			<div class="formitems is_new_hidden">
		        <label class="fi-name"><span class="colorRed">*</span>推荐人ID：</label>
		        <div class="form-controls" id="topUser">
		            <input type="text" class="input large" name="refer_uid" autocomplete="off">
	                <span class="fi-help-text " style="color:red;"></span>
		        </div>
		    </div>
	    </div>
            <div class="formitems">  
                    <label class="fi-name"><span class="colorRed">*</span>选择商品 ：</label>
                    <div class="form-controls">
                        <?php foreach($goodsList as $goods) { ?>
                        <label><input type="radio"  value="<?=$goods['goods_id']?>" name="goods_id" ><?=$goods['goods_name']?></label>
                        <?php } ?>
                        <span class="fi-help-text " style="color:red;"></span>
                    </div>
                </div>
	    
		<div class="formitems">  
			<label class="fi-name"><span class="colorRed">*</span>报单盒数 ：</label>
			<div class="form-controls">
				<input  type="text" id="number" class="input large" name="number" >
                                <span class="fi-help-text " style="color:red;">盒数为0时只录入用户，不分佣金</span>
			</div>
		</div>
            
                <div class="formitems">  
			<label class="fi-name"><span class="colorRed"></span>收货地址 ：</label>
			<div class="form-controls">
				<input  type="text"  class="input large" name="address" >
                                <span class="fi-help-text " style="color:red;"></span>
			</div>
		</div>
		
		<div class="mgl120">
			<a href="javascript:tijiaodata();" class="btn btn-primary j-add">确认报单</a>
		</div>
	</form>
</div>
<script>

function tijiaodata(){
	var title = "以上数据非常重要,你确定要继续提交新数据吗?";
	
	layer.confirm(title, {
	    btn: ['确定','我再想想'] //按钮
	}, function(){
		postUpgrade();
	}, function(){
		layer.msg('你取消了提交', {icon: 7});
	});
}
function postUpgrade(formId, post) {
	console.log(11);
    // 表单不存在 则直接返回
    if(!formId){
        var formId = "form";
    }
    if ($('#' + formId).length == 0) {
        return false;
    }
    var action = $('#' + formId).attr('action');
    if (!action) {
        action = location.href;
    }
    if (!post) {
        post = 'post';
    }
    $.ajax({
        url : action,
        type : post,
        data : $('#' + formId).serialize(),
        dataType : 'json',
        success : function(data) {
            layer.closeAll('loading');//关闭正在加载
            if (data.url) {
                // 如果有跳转地址
                layer.alert(data.msg, {icon: 6}, function(){
                    window.location.href = data.url;//跳转
                }); 
                
            } else {
            	layer.alert(data.msg, {icon: 6});
            }
        },
        beforeSend:function(){
            layer.load();//正在加载
       },
       error: function() {
           layer.closeAll('loading');//关闭正在加载
           layer.msg("网络错误,请重试", {icon: 2});
       }
       
    });
}

$('.order_type').on('change',function(){
	var type = $(this).val();
	if(type == 1){
		$('#type1').show();
		$('#relaname_text').text('新合伙人姓名');
		$('#mobile_text').text('新合伙人手机号');
	}else{
		$('#type1').hide();
		$('#relaname_text').text('下单人姓名');
		$('#mobile_text').text('下单人手机号');
	}
})
$('.order_type').change();

</script>